import mongoose from "mongoose"

const cartScheme = mongoose.Schema({
  user: {
    type: mongoose.Schema.Types.ObjectId, // 其他模型的id
    required: true,
    ref: 'User', // 关联用户
  },
  product: {
    type: mongoose.Schema.Types.ObjectId,
    required: true,
    ref: "Product"
  },
  qty: {
    type: Number,
    required: true
  }
}, {
  timestamps: true, // 更新时更新时间
})

const Cart = mongoose.model("Cart", cartScheme)

export default Cart